<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="ZH-CN">
<head>
</head>
<body>
<script type="text/javascript">
$(function(){
			
			$('#type').combobox({
				url:'${pageContext.request.contextPath}/dissType',
				editable:false,
				method:'post',
				valueField:'value', 
				textField:'text',
				required:true,
				panelHeight : 'auto',
			});
			$('#res').combobox({
				url:'${pageContext.request.contextPath}/thesissource',
				editable:false,
				method:'post',
				valueField:'thesissource_id', 
				textField:'thesissource_name',
				required:true,
				panelHeight : 'auto',
			});
			$('#method').combobox({
				url:'${pageContext.request.contextPath}/method',
				editable:false,
				method:'post',
				valueField:'value', 
				textField:'text',
				required:true,
				panelHeight : 'auto',
				onSelect : function(rec) {
					if(rec.value=="C"){
					var url = '${pageContext.request.contextPath}/TeaStu';
					$('#stu').combobox('reload', url);
					$('#stu').combobox('clear');
					$('#stu').combobox({
						required:true,
					});
					}
					else{
					$('#stu').combobox('loadData', {});
					$('#stu').combobox('clear');
					}
				}
			});
			$('#stu').combobox({
				url:'',
				editable:false,
				method:'post',
				valueField:'student_id', 
				textField:'Sin',
				panelHeight : 'auto',
			});
	}
)
function save(){
			console.info($('#dd'));
 			var name=document.getElementById("name").value;
 			var source = $('#res').combobox('getValue');
 			var type = $('#type').combobox('getValue');
 			var method = $('#method').combobox('getValue');
 			var stu = $('#stu').combobox('getValue');
 			console.info(name.length);
 			if(name.length&&type.length&&method.length>0){
			$.ajax({
							
							type:'post',
							url : '${pageContext.request.contextPath}/add',
							data : {
								thesistitle_name:name,
								thesistitle_source:source,
								thesistitle_type:type,
								thesistitle_select_way:method,
								stu:stu,
								
							},
							dataType : 'json',
							success : function(r) {
										$('#dd').dialog('close');
										$('#dissertation').datagrid('load');
								},
								error : function(r) {
									$.messager.alert('Warning', r.msg);
							}	
						});
 			} else{
 				$.messager.alert('error', '必填选项不能为空')
 			}
			}
function closed(){
				$('#dd').dialog('close');
}
</script>
	<div >
	课题名称：<input class="easyui-validatebox" id="name" data-options="required:true" style="width:100%"><br/>
	课题类型：<input id="type"><br/>
	课题来源：<input id="res"><br/>
	选题方式：<input id="method"><br/>
	选题学生：<input id="stu"><br/>
	<a type="button" class="btn btn-success" onclick="save()">保存</a>
	<a type="button" class="btn btn-primary" onclick="closed()">关闭</a>
	</div> 
	
</body>